<!doctype html>
<html lang="en" class="no-js">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	
	<title>Peoples: Login</title>
	<meta name="description" content="">
	<meta name="author" content="">
	
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<link rel="shortcut icon" href="/favicon.ico">
	<link rel="stylesheet" href="../_core/style.css?v=2">
	<link rel="stylesheet" href="crm.css">
	<link rel="stylesheet" href="login.css">

    <script src="../_core/jquery-1.6.min.js"></script>
    <script src="../_core/jquery-ui-1.8.12.custom.min.js"></script>
    <script src="../_core/sammy/sammy-0.6.3.min.js"></script>
	<script src="../_core/sammy/plugins/sammy.json-latest.min.js"></script>
    <script src="../_core/sammy/plugins/sammy.storage-latest.min.js"></script>
    
</head>
<body>
	<?php
	
	// check form submission
	if (isset($_POST['submit'])) {
        $url = $_POST['url'];
        $username = $_POST['username'];
        $password = $_POST['password'];
        
        // TODO: do a real check here (currently a dummy)
        if ($username == 'abeyang') {
    ?>
            <script>
                var storage = new Sammy.Store({name: 'peoples', type: 'local'});
                storage.set('userid', 1);
                storage.set('username', 'Abe Yang');
                window.location = "index.html#/<?php echo $url ?>";
            </script>

    <?php 
        }
	}

	// otherwise, entering form for the first time...
	else {
	    $url = $_GET['url'];
	}
	
	?>
	
	<div id="login">
            <form action="login.php" method="post">
                <input type="hidden" name="url" value="<?php echo $url; ?>" id="url">
                <p><label>Username</label><input type="text" name="username" value="<?php echo $username; ?>" id="username"></p>
                <p><label>Password</label><input type="password" name="password" value="<?php echo $password; ?>" id="password"></p>
                <p><input type="submit" name="submit" id="submit" value="Submit"></p>
            </form>
	</div> <!-- end #login -->

    

</body>
</html>